package com.icode.gulimall.ware.dao;

import com.icode.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 商品库存
 * 
 * @author my_code
 * @email my_code@foxmail.com
 * @date 2020-11-21 23:12:34
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("stock") Integer skuNum);

    Long queryStockBySkuId(@Param("skuId") Long skuId);

    List<WareSkuEntity> selectBySkuIds(@Param("skuIds") Set<String> skuIds);

    int lockStockBySkuId(@Param("skuId") Long skuId, @Param("count") Integer count, @Param("wareId") Integer wareId);

    void releaseStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);
}
